package util;

import java.util.Properties;
import org.hibernate.*;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import entities.*;

public abstract class SessionManager {

private static SessionFactory factory;
    

    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
             config.addAnnotatedClass(Clase.class);
             config.addAnnotatedClass(Cliente.class);
             config.addAnnotatedClass(CuotaPaga.class);
             config.addAnnotatedClass(DatosFisicos.class);
             config.addAnnotatedClass(Ejercicio.class);
             config.addAnnotatedClass(ItemRutina.class);
             config.addAnnotatedClass(Locker.class);
             config.addAnnotatedClass(Maquina.class);
             config.addAnnotatedClass(OpcionDias.class);
             config.addAnnotatedClass(OpcionHoraria.class);
             config.addAnnotatedClass(Profesor.class);
             config.addAnnotatedClass(Rutina.class);
             sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
